
package com.example.demo.controller;

import com.baomidou.mybatisplus.core.metadata.IPage;
import com.xiaohei.crm.common.result.Result;
import com.xiaohei.crm.dao.Inventory;
import com.xiaohei.crm.service.InventoryService;
import lombok.RequiredArgsConstructor;
import org.springframework.web.bind.annotation.*;


@RestController
@CrossOrigin
@RequiredArgsConstructor
public class InventoryController {

    private final InventoryService inventoryService;

    /**
     * 分页查询区域信息
     * @return
     */
    @GetMapping("/inventory/findByPage")
    public Result<IPage> findByPage(Integer pageIndex, Integer pageSize, String equipmentName, String areaName){
        return inventoryService.findByPage(pageIndex, pageSize, equipmentName, areaName);
    }

    /**
     * 添加用户
     * @param
     * @return
     */
    @PostMapping("/inventory")
    public Result save(@RequestBody Inventory inventory){
        inventoryService.saveInventory(inventory);
        return Result.ok();
    }

    /**
     * 逻辑删除区域
     * @param
     * @return
     */
    @DeleteMapping("inventory/{id}")
    public Result<String> deleteByInventoryId(@PathVariable("id") String id){
        inventoryService.removeByInventoryId(id);
        return Result.ok();
    }

}
